Imports BlazeApps.Library.Form

Partial Class Usercontrols_Form_FormAnalysis
    Inherits UserControlBase

#Region " Enums, Memebers and Properties "

    Protected Property FormGuid() As Guid
        Get
            Return GetGuidFromVS("FormID")
        End Get
        Set(ByVal value As Guid)
            ViewState.Add("FormID", value)
        End Set
    End Property

    Protected Property FormResponseGuid() As Guid
        Get
            Return GetGuidFromVS("FormResponseID")
        End Get
        Set(ByVal value As Guid)
            ViewState.Add("FormResponseID", value)
        End Set
    End Property

#End Region

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        GetQueryStringValues()

        If Page.IsPostBack = False Then
            LoadResults()
        End If

        BuildPage(FormGuid, FormResponseGuid, Me.uxMatrixResultsPlaceHolder, "formsystem", False, True)
    End Sub

    Private Sub LoadResults()
        'Dim List As FormList = New FormList()

        'With Me.uxFormResultsRepeater
        '    .DataSource = List.GetAnswerResults(FormGuid)
        '    .DataBind()
        'End With

    End Sub

    Protected Sub uxFormResultsRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles uxFormResultsRepeater.ItemDataBound
        Dim TB As HtmlTable = CType(e.Item.FindControl("ResultsTable"), HtmlTable)

        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

            If Convert.ToInt32(e.Item.DataItem("resultpercentage")) > 0 Then
                TB.Style.Add("width", String.Format("{0}%", e.Item.DataItem("resultpercentage")))
            End If

        End If

    End Sub

#Region " Helpers and Methods "

    Protected Sub GetQueryStringValues()
        FormGuid = GetGuidFromQueryString("FormID")
        FormResponseGuid = GetGuidFromQueryString("FormResponseID")
    End Sub

#End Region

End Class
